/**
 * @file bull_hal_drv_flash.h
 * @brief 
 * @author yejing (yejh@gongniu.cn)
 * @version 1.0
 * @date 2024-05-11
 * 
 * Copyright 2021-2023 GongNiu Inc. All Rights Reserved.
 * 
 */

#ifndef BULL_HAL_DRV_FLASH_H
#define BULL_HAL_DRV_FLASH_H

#include "bull_hal_adapter.h"

#ifdef __cplusplus
extern "C" {
#endif 

/**
 * @brief read data from flash
 * 
 * @param[in]       addr        flash address
 * @param[out]      dst         pointer of buffer
 * @param[in]       size        size of buffer
 * @return int 0=成功，非0=失败
 */
int bull_hal_drv_flash_read( BULL_FLASH_PART_ENUM part,const unsigned int offset_addr, unsigned char *dst, const unsigned int size);

/**
 * @brief write data to flash
 * 
 * @param[in]       addr        flash address
 * @param[in]       src         pointer of buffer
 * @param[in]       size        size of buffer
 * @return int 0=成功，非0=失败
 */
int bull_hal_drv_flash_write(BULL_FLASH_PART_ENUM part,const unsigned int offset_addr, const unsigned char *src, const unsigned int size);

/**
 * @brief erase flash block
 * 
 * @param[in]       addr        flash block address
 * @param[in]       size        size of flash block
 * @return int 0=成功，非0=失败
 */
int bull_hal_drv_flash_erase(uint8_t part,const unsigned int offset_addr, const unsigned int size);


#ifdef __cplusplus
}
#endif

#endif 

